package com.company.algo.huawei;

/**
 * 性价比最高，
 * 性价比：投影长度/price
 *      投影长度：x2-x1
 *      price: sqrt(pow(x2-x1,2)+pow(y2-y1,2)) * s
 * 暴力：
 *    遍历所有雨棚，记录最大性价比雨棚的下标\
 * 剪枝，记cover_1 = (input[0][0]-input[0][1])
 *      则当cover_i>cover_j且s_i>s_j时，跳过input[j]
 */
public class yupeng {
    static class Canopy{
        double x1,x2;
        double y1,y2;
        double s;
        double effect;
        public Canopy(double x1,double x2, double y1, double y2, double s){
            this.x1 = x1;
            this.x2 = x2;
            this.y1 = y1;
            this.y2 = y2;
            this.s = s;
            double price = Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2))*s;
            this.effect = (x2-x1)/price;
        }
    }

    public static void main(String[] args) {
        double[] input1 = {1,2,2,2,2};
        double[] input2 = {1,2,2,2,2};
        double[] input3 = {1,2,2,1,1.5};
        int n = 3;
        double[][] input = new double[n][];
        input[0] = input1;
        input[1] = input2;
        input[2] = input3;
        double maxEff = Double.MIN_VALUE;
        int res = -1;
        for (int i = 0; i < n; i++) {
            Canopy canopy = new Canopy(input[i][0],input[i][1],input[i][2],input[i][3],input[i][4]);
            if (maxEff < canopy.effect){
                maxEff = canopy.effect;
                res = i;
            }
        }
        System.out.println(res);
    }
}
